home *** CD-ROM | disk | FTP | other *** search
- ; VERY, VERY simple ANSI/text viewer
- ;
- ; Coded by Draeden [VLA]
- ;
-
- DOSSEG
- .MODEL SMALL
- .STACK 200h
- .CODE
- Ideal
-
- ;===- Data -===
-
- BufferSeg dw 0
-
- ErrMsgOpen db "Error opening `"
- FileName db "ANSI.TXT",0,8,"'$" ;8 is a delete character
- ;0 is required for filename
- ;(displays a space)
- FileLength dw 0
-
- ;===- Subroutines -===
-
- PROC DisplayFile NEAR
- push ds
-
- mov ax,cs
- mov ds,ax
- mov ax,3d00h ;open file (ah=3dh)
- mov dx,offset FileName
- int 21h
- jc OpenError
- mov bx,ax ;move the file handle into bx
-
- mov ds,[BufferSeg]
- mov dx,0 ;load to [BufferSeg]:0000
- mov ah,3fh
- mov cx,0FFFFh ;try to read an entire segments worth
- int 21h
-
- mov [cs:FileLength],ax
-
- mov ah,3eh
- int 21h ;close the file
-
- cld
- mov si,0
- mov cx,[cs:FileLength]
- PrintLoop:
- mov ah,2
- lodsb
- mov dl,al
- int 21h ;print a character
-
- dec cx
- jne PrintLoop
-
- pop ds
- ret
-
- OpenError:
- mov ah,9
- mov dx,offset ErrMsgOpen
- int 21h
-
- pop ds
- ret
- ENDP DisplayFile
-
- ;===- Main Program -===
-
- START:
- mov ax,cs
- mov ds,ax
- mov bx,ss
- add bx,200h/10h ;get past the end of the file
- mov [BufferSeg],bx ;store the buffer segment
-
- call DisplayFile
-
- mov ax,4c00h
- int 21h
- END START
-
-